import { Component, OnInit, ViewChild, Input, Output, EventEmitter } from '@angular/core';
import { InitService } from '../../public/serve/init/init.service';
import { RemoveTableService } from '../../public/serve/remove-table/remove-table.service';
import { CudTableService } from '../../public/serve/cud-table/cud-table.service';
import { Service } from '../../server/server';
import { HintsService } from '../../public/serve/hints/hints.service';
import { keyword } from '../keyword.data';
import { appKeywordUrl } from '../keyword.url';
import { TrialTableComponent } from '../trial/trial-table/trial-table.component';

declare var $:any;
@Component({
  selector: 'app-unreviewed',
  templateUrl: './unreviewed.component.html',
  styleUrls: ['./unreviewed.component.css']
})
export class UnreviewedComponent implements OnInit {

  @ViewChild("table") table : TrialTableComponent;

  pageNo : number = 0;

  checkStatus: number;
  right: any = {
    "keywordTrial": {},
    "keywordUnreviewed": {}
  };

  constructor(
    public initService: InitService,
    public removeTableService: RemoveTableService,
    public request: CudTableService,
    public server: Service,
    private hintsService: HintsService
  ) {
    this.right = $.extend(this.right, server.getRight());
   }

  isActive = this.server.isActive;
  ngOnInit() {
    this.server.eventEmit.subscribe((value: any)=>{
      this.isActive = value;
    });
  }

  /**
   * 已审或未审tab切换
   */
  _isStatus(tid){
    if(this.table){
      keyword.retrieval.themeTableId=tid;
      keyword.retrieval.queryCriteria = '';
      keyword.retrieval.status = '';
      keyword.retrieval.labelId = '';
    }
  }

/**
   * 搜索
   * @param val
   */
  _retrieval(val:string){
    keyword.retrieval.queryCriteria = val.trim();
    this.table._keyworkTabList();
  }

 /**
   * 分页
   * @param pagination 
   */ 
  _pagination(pagination: Array<any>) {
    keyword.pagination.pageNo = pagination[0].pageNumber;
    keyword.pagination.pageSize   = pagination[0].pageSize;
    keyword.pagination.naturalNum = (keyword.pagination.pageNo - 1) * keyword.pagination.pageSize;
    this.table._keyworkTabList();
  }

}
